﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Yugi.Client.Card;
namespace Yugi.Client.Control
{
	/// <summary>
	/// Interaction logic for YCardDetail.xaml
	/// </summary>
	public partial class YCardDetail : UserControl
	{
        ViewDetailModel model;
		public YCardDetail()
		{
			this.InitializeComponent();
            this.DataContextChanged += new DependencyPropertyChangedEventHandler(YCardDetail_DataContextChanged);
		}

        void YCardDetail_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            model = this.DataContext as ViewDetailModel;
            if (model == null) return;
            model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(obj_PropertyChanged);
            if (model.Card != null)
            {
                this.image.Opacity = 0;
                image.Source = model.Card.displayImage;
                Storyboard s = this.Resources["Show"] as Storyboard;
                s.Begin(this);
                
            }
        }

        void obj_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Card")
            {
                this.image.Opacity = 0;
                image.Source = model.Card.displayImage;
                Storyboard s = this.Resources["Show"] as Storyboard;
                s.Begin(this);
            }
        }

    
	}
    
}